Skip to content

Fix change-project auth issue#148

Merged
dwilding merged 7 commits intocanonical:next-releasefrom
evildmp:fix-change-project-auth-issue
Apr 26, 2026
Merged

Fix change-project auth issue#148
dwilding merged 7 commits intocanonical:next-releasefrom
evildmp:fix-change-project-auth-issue

Conversation

@evildmp
Copy link
Copy Markdown
Collaborator

@evildmp evildmp commented Apr 20, 2026

Based on #147, merge after merging that.

Added a permissions constraint for project_basic_form_save

This fixes an auth issue. It was possible to POST a
change to a project, without even being authenticated.
The only safeguard was the user interface, that didn't
offer make it possible.

This adds @permission_required("projects.change_project")
to the view, and some tests.

  • added a fixture for a user with permission to change a project
  • added a test: do we reject changes from unauthenticated users?
  • added a test: do we reject changes from unauthorised users?
  • added a test: do we allow and save changes from users with the right permissions?

I used Copilot to uncover the issue and help create the tests.

evildmp added 4 commits April 20, 2026 05:05
This allows tests in environments that haven't loaded OIDC to continue
running.

See https://docs.pytest.org/en/latest/reference/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files
for notes on shared fixtures.
Updated:

test_toggle_condition_url_patterns (Simplified, and now only checks the
reversed route, rather than the string)

New checks for user permissions:

* test_action_toggle_commitment_denies_user_without_permission
* test_action_toggle_condition_denies_user_without_permission
* test_action_select_reason_denies_user_without_permission

New checks for HTTP methods:

* test_action_toggle_commitment_rejects_non_put_method
* test_action_toggle_condition_rejects_non_put_method
* test_action_select_reason_rejects_non_put_method

New checks for expected results:

new: test_action_toggle_commitment_allows_authorized_put_and_updates_commitment
new: test_action_toggle_condition_allows_authorized_put_and_updates_status
new: test_action_select_reason_allows_authorized_put_and_sets_reason

I used Copilot to help create these tests.
This fixes an auth issue. It was possible to POST a
change to a project, without even being authenticated.
The only safeguard was the user interface, that didn't
offer make it possible.

This adds @permission_required("projects.change_project")
to the view, and some tests.

* added a fixture for a user with  permission to change a project
* added a test: do we reject changes from unauthenticated users?
* added a test: do we reject changes from unauthorised users?
* added a test: do we allow and save changes from users with the right permissions?

I used Copilot to uncover the issue and help create the tests.
This fixes an auth issue. It was possible to POST a
change to a project, without even being authenticated.
The only safeguard was the user interface, that didn't
offer make it possible.

This adds @permission_required("projects.change_project")
to the view, and some tests.

* added a fixture for a user with  permission to change a project
* added a test: do we reject changes from unauthenticated users?
* added a test: do we reject changes from unauthorised users?
* added a test: do we allow and save changes from users with the right permissions?

I used Copilot to uncover the issue and help create the tests.
Copy link
Copy Markdown
Collaborator

@dwilding dwilding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch & tests, thanks. I moved the user_can_change_project fixture to conftest.py along with the other user-based fixtures.

@dwilding dwilding changed the title Fix change project auth issue Fix change-project auth issue Apr 26, 2026
@dwilding dwilding merged commit e9f91b8 into canonical:next-release Apr 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants